package com.dmap.admin.controller.rpc;

import com.dmap.admin.bo.backgroundv2.AppBo;
import com.dmap.admin.po.App;
import com.dmap.admin.service.backgroundv2.AppService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.apache.commons.lang.StringUtils;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.annotation.Resource;
import java.util.List;

/**
 * \* User: helei
 * \* Date: 19/06/18
 * \* Description:
 * \
 */
@Api(value = "个人数据服务系统-Rpc-App管理", description = "background/Rpc-App管理")
@Controller
@RequestMapping(value = "/rpc/background/pmpd-admin-server/v2/app/")
public class RpcAppController {

    @Resource
    private AppService appService;

    @ResponseBody
    @ApiOperation(value = "根据id查询app", notes = "1. 必填： id;")
    @RequestMapping(value = "select/selectById", method = RequestMethod.GET)
    public AppBo selectById(@RequestParam String id) {
        AppBo appBo = null;
        if (StringUtils.isBlank(id) || !StringUtils.isNumeric(id) || Long.valueOf(id).equals(0L)) {
            return appBo;
        }
        App selectById = appService.selectById(Long.valueOf(id));
        if (selectById != null) {
            appBo = new AppBo(selectById);
        }
        return appBo;
    }

    @ResponseBody
    @ApiOperation(value = "查询所有的projectId")
    @RequestMapping(value = "select/selectAllProjectId", method = RequestMethod.GET)
    public List<String> selectAllProjectId() {
        return appService.selectAllProjectId();
    }

}